package pers.qianyu.month_202101.date_20210123;

/**
 * 278. 第一个错误的版本
 * https://leetcode-cn.com/problems/first-bad-version/
 *
 * @author mizzle rain
 * @date 2021-01-23 19:33
 */
public class FirstBadVersion {
    boolean isBadVersion(int version) {
        return true;
    }

    public int firstBadVersion(int n) {
        int left = 1, right = n;
        while (left < right) {
            int mid = left + ((right - left) >> 1);
            if (isBadVersion(mid)) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return left;
    }
}
